# install.packages("lpSolveAPI")
# install.packages("readstata13")
# install.packages("dplyr")

# Clear all
rm(list = ls()) 

#Load Packages
library(lpSolveAPI)
library(readstata13)
library(dplyr)

# Set Path
setwd(paste0("***"))

# Load Function "acr_bounds"
source("Code/function.R")

# The function takes arguments (concavity_assumption, weights, acr).
# 1. concavity_assumption = 1 if beta_{m} > beta_{m+1}, 0 otherwise
# 2. weights is the vector type containing the appropriate weights
# 3. acr should be the appropriate value type containing the ACR
# Outputs Lower Bound, Upper Bound, and values of betas in both cases

# Input observed weights as a vector
aca_weights <- read.dta13("Results/Data/aca_weights_072020.dta") 
aca_weights <- as.vector(aca_weights[,1])

# Specify ACR (absolute value)
acr <- abs(-0.17757)

# LP Result assuming concavity
results_conc <- acr_bounds(1,aca_weights,acr)

# Display Lower Bound and Upper Bound
results_conc[["Lower Bound"]]
results_conc[["Upper Bound"]]
